﻿using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Rex.Assignment.Application.AppUsers;
using Rex.Assignment.Application.AppUsers.Dtos;
using Rex.Assignment.Application.AppUsers.Pos;
using Rex.Assignment.Common;
using StatusCodes = Rex.Assignment.Common.StatusCode;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace Rex.Assignment.WebApi.Controllers
{
    [Route("api/Login")]
    [ApiController]
    public class LoginController : ControllerBase
    {
        private readonly ILoginService _loginService;

        public LoginController(ILoginService loginService)
        {
            _loginService = loginService;
        }

        /// <summary>
        /// 登录验证
        /// </summary>
        /// <param name="loginVerification">登录验证参数</param>
        /// <returns></returns>
        [Route("Verification")]
        [HttpPost]
        public DataResult<SysUserDto> GetVerificationLogin([FromBody] LoginVerificationPo loginVerification)
        {
            if (ModelState.IsValid)
            {
                var result = _loginService.VerificationLogin(loginVerification);
                return result;
            }
            return new DataResult<SysUserDto>()
            {
                Code = StatusCodes.Error,
                Msg = "登录验证失败！"
            };
        }

    }
}
